<?php
namespace Home\Controller;

class StaffController extends HomeController {

   //职位数据列表
    public function getList() {
        if(IS_AJAX) {
            $this->ajaxReturn(D('Staff')->getList(
                I('post.sort'),
                I('post.order'),
                I('post.page'),
                I('post.rows'),
                I('post.keywords'),
                I('post.dateType'),
                I('post.dateFrom'),
                I('post.dateTo'),

                I('post.id_card'),
                I('post.nation'),
                I('post.gender'),
                I('post.marital_status'),
                I('post.type'),
                I('post.post'),
                I('post.entry_status'),
                I('post.education')
            ));

        } else {
            $this->error('非法操作');
       }
    }
    //帐号新增时 获取关联 档案数据
    public function getNotRelationList() {
        if(IS_AJAX) {
            $this->ajaxReturn(D('Staff')->getNotRelationList(
                I('post.sort'),
                I('post.order'),
                I('post.page'),
                I('post.rows')
            ));

        } else {
            $this->error('非法操作');
        }
    }

    //后台 新增帐号 操作
    public function register() {
        if(IS_AJAX) {
            $Staff = D('Staff');
            echo $Staff->register(I('post.name'),
                                  I('post.number'),
                                  I('post.tel'),
                                  I('post.post'),
                                  I('post.id_card'),
                                  I('post.intro'),
                                  I('post.registered_address'),
                                  I('post.registered'),
                                  I('post.politics_status'),
                                  I('post.details'),
                                  I('post.nation'),
                                  I('post.dimission_date'),
                                  I('post.education'),
                                  I('post.gender'),
                                  I('post.health'),
                                  I('post.graduate_date'),
                                  I('post.graduate_colleges'),
                                  I('post.entry_date'),
                                  I('post.entry_status'),
                                  I('post.marital_status'),
                                  I('post.type'),
                                  I('post.specialty')
            );
        } else {
            $this->error('非法操作');
        }

    }

    //根据ID 获取一条编辑的数据
    public function getOne() {
        if(IS_AJAX) {
            $Staff = D('Staff');
            $this->ajaxReturn($Staff->getOne(I('post.id')));
        } else {
            $this->error('非法操作');
        }

    }

    //根据ID 获取一条编辑的数据
    public function getDetails() {
        if(IS_AJAX) {
            $Staff = D('Staff');
            $this->assign('object',$Staff->getOne(I('get.id')));
            $this->display('details');
        } else {
            $this->error('非法操作');
        }

    }

    //根据ID 修改一条帐号数据
    public function update() {
        if(IS_AJAX) {
            $Staff = D('Staff');
            echo $Staff->update(I('post.id'),
                                I('post.name'),
                                I('post.number'),
                                I('post.tel'),
                                I('post.post'),
                                I('post.id_card'),
                                I('post.intro'),
                                I('post.registered_address'),
                                I('post.registered'),
                                I('post.politics_status'),
                                I('post.details'),
                                I('post.nation'),
                                I('post.dimission_date'),
                                I('post.education'),
                                I('post.gender'),
                                I('post.health'),
                                I('post.graduate_date'),
                                I('post.graduate_colleges'),
                                I('post.entry_date'),
                                I('post.entry_status'),
                                I('post.marital_status'),
                                I('post.type'),
                                I('post.specialty'));
        } else {
            $this->error('非法操作');
        }
    }



    //根据ID 删除一条或者多条数据
    public function remove() {
        if (IS_AJAX) {
            $Staff = D('Staff');
            echo $Staff->remove(I('post.ids'));
        }
    }



}